/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package healthcare.coursework.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Administrator
 */
@Entity
@Table(name = "DIAGNOSES")
@NamedQueries({
    @NamedQuery(name = "Diagnoses.findAll", query = "SELECT d FROM Diagnoses d")})
public class Diagnoses implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected DiagnosesPK diagnosesPK;
    @Basic(optional = false)
    @Column(name = "APPOINT_TIME", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date appointTime;
    @Basic(optional = false)
    @Column(name = "IS_CANCELED", nullable = false)
    private boolean isCanceled;
    @JoinColumn(name = "USERNAME", referencedColumnName = "USERNAME", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Users user;
    @JoinColumn(name = "SERVICE_ID", referencedColumnName = "SERVICE_ID", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Service service;
    @JoinColumn(name = "PATIENT_ID", referencedColumnName = "PATIENT_ID", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Patient patient;

    public Diagnoses() {
    }

    public Diagnoses(DiagnosesPK diagnosesPK) {
        this.diagnosesPK = diagnosesPK;
    }

    public Diagnoses(DiagnosesPK diagnosesPK, Date appointTime, boolean isCanceled) {
        this.diagnosesPK = diagnosesPK;
        this.appointTime = appointTime;
        this.isCanceled = isCanceled;
    }

    public Diagnoses(long patientId, String username, int serviceId) {
        this.diagnosesPK = new DiagnosesPK(patientId, username, serviceId);
    }

    public DiagnosesPK getDiagnosesPK() {
        return diagnosesPK;
    }

    public void setDiagnosesPK(DiagnosesPK diagnosesPK) {
        this.diagnosesPK = diagnosesPK;
    }

    public Date getAppointTime() {
        return appointTime;
    }

    public void setAppointTime(Date appointTime) {
        this.appointTime = appointTime;
    }

    public boolean getIsCanceled() {
        return isCanceled;
    }

    public void setIsCanceled(boolean isCanceled) {
        this.isCanceled = isCanceled;
    }

    public Users getUser() {
        return user;
    }

    public void setUser(Users user) {
        this.user = user;
    }

   

    public Service getService() {
        return service;
    }

    public void setService(Service service) {
        this.service = service;
    }

    public Patient getPatient() {
        return patient;
    }

    public void setPatient(Patient patient) {
        this.patient = patient;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (diagnosesPK != null ? diagnosesPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Diagnoses)) {
            return false;
        }
        Diagnoses other = (Diagnoses) object;
        if ((this.diagnosesPK == null && other.diagnosesPK != null) || (this.diagnosesPK != null && !this.diagnosesPK.equals(other.diagnosesPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "healthcare.coursework.model.Diagnoses[diagnosesPK=" + diagnosesPK + "]";
    }

}
